package org.forex.impl.engine;

import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;

public class InstrumentSteps{
	InstrumentChoice insc;
	InstrumentTrend at;
 
	@Given("an instrument with code $code and price $price")
	public void givenXValue(@Named("code") String code,@Named("price") double price) throws IOException {
		insc=new InstrumentChoice();
		insc.setStartPrice(price);
		insc.setCode(code);
	}
 
	@When("the price increment to $price")
	public void whenPrice(@Named("price") double price) throws Exception {
		at=new InstrumentTrend();
		at.setCurrentPrice(insc,price);
	}
 
	@Then("the buy order must be $orderType")
	public void thenCheckTheOrderBuy(@Named("orderType") String orderType) throws IOException {
		assertTrue(orderType.equalsIgnoreCase(at.getOrderTrend(insc)));
	}
	
	@When("the price decrement to $price")
	public void whenPrice1(@Named("price") double price) throws Exception {
		at.setCurrentPrice(insc,price);
	}
 
	@Then("the sell order must be $orderType")
	public void thenCheckTheOrderSell(@Named("orderType") String orderType) throws IOException {
		assertTrue(orderType.equalsIgnoreCase(at.getOrderTrend(insc)));
	}
	
}